package com.dxysun.springboot;

import java.util.Arrays;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;

import com.dxysun.springboot.state.IOrderService;

@SpringBootApplication(exclude =
{ KafkaAutoConfiguration.class })
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableAsync(proxyTargetClass = true)
//@ServletComponentScan(basePackages = {"com.dxysun.springboot.filter"})
public class Application
{

	public static ApplicationContext context;

	public static void main(String[] args)
	{
		System.out.println(Arrays.toString(args));
		context = SpringApplication.run(Application.class, args);
	}

	public static void orderStateTest()
	{
		IOrderService orderService = (IOrderService) context.getBean("orderService");
		orderService.create();
		orderService.create();
		orderService.pay(1);
		new Thread("客户线程") {
			@Override
			public void run()
			{
				orderService.deliver(1);
				orderService.receive(1);
			}
		}.start();
		orderService.pay(2);
		orderService.deliver(2);
		orderService.receive(2);
		System.out.println("全部订单状态:" + orderService.getOrders());
	}

}
